package com.kele.auth.feign.fallback;

import com.kele.auth.feign.UserFeignClient;
import com.kele.auth.util.SecurityUtil;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @Description:
 * @Author: Kele
 * @CreateDate: 2023/4/23 18:26
 * @Version:
 */
public class UserClientFactory implements FallbackFactory<UserFeignClient> {

    private static final Logger log = LoggerFactory.getLogger(UserClientFactory.class);

    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {

            @Override
            public SecurityUtil.User getUserByUsername(String username){
                log.debug("调用系统服务熔断异常:{}", throwable.getMessage());
                return null;
            }

            @Override
            public List<String> getAuthorities(String userId) {
                log.debug("调用系统服务熔断异常:{}", throwable.getMessage());
                return null;
            }
        };
    }
}
